package cn.yitun.chat.yitunserverimcore.general.main.push.voice;

import cn.yitun.chat.yituncommonmessage.impl.HeadImpl;
import cn.yitun.chat.yituncommonmessage.push.PushMessage;
import cn.yitun.chat.yitunservercommonlib.constant.ActionTypeConstant;
import cn.yitun.chat.yitunservercommonlib.enums.control.push.voice.VoicePushMethodEnum;
import cn.yitun.chat.yitunserverimcore.bridge.net.WriteHandler;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 音频相关推送
 * @author yitun
 * @since 1.1
 */
@Service
public class VoicePush {
	//1.5.003
	final String action = ActionTypeConstant.VOICE_ACTION_PUSH;

	@Resource
	WriteHandler writeHandler;

	/**
	 * 音频接收地址
	 * @param userId
	 */
	public void pushReceivedVoiceAddress(Long userId) {
		HeadImpl head = new HeadImpl();
		head.setAction(action);
		head.setMethod(VoicePushMethodEnum.RECEIVED_VOICE_ADDRESS.getMethod());
		head.setTimestamp(System.currentTimeMillis());
		PushMessage message = new PushMessage();
		message.setHead(head);
		writeHandler.push(userId, message);
	}
}
